<template>
  <demoBlock title="异步关闭">
    <vcu-swipe-cell :before-close="beforeClose">
      <template #left>
        <vcu-button square type="primary" text="选择" />
      </template>
      <vcu-cell :border="false" title="单元格" value="内容" />
      <template #right>
        <vcu-button square type="danger" text="删除" />
      </template>
    </vcu-swipe-cell>
  </demoBlock>
</template>

<script setup lang="ts">
const beforeClose = ({ position }: { position: string }) => {
  switch (position) {
    case "left":
    case "cell":
    case "outside":
      return true;
    case "right":
      return new Promise((resolve) => {
        setTimeout(() => {
          console.info("删除成功");
          resolve(true);
        }, 1000);
      });
  }
};
</script>
